package multithread;

//信号量
import java.util.concurrent.Semaphore;

public class ThreadDemo17 {
    public static void main(String[] args) throws InterruptedException {
        //参数为可用资源的个数
        Semaphore semaphore = new Semaphore(1);

        semaphore.acquire();
        System.out.println("P操作");
        semaphore.acquire();
        System.out.println("P操作");
        semaphore.acquire();
        System.out.println("P操作");
        semaphore.release();
    }
}


